<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>TEST!</title>
		<meta name="author" content="Oded Idan" />
		<link rel="stylesheet" type="text/css" href="css/tests.css" />
		<script src="../client/cauth.js"></script>
		<script type="text/javascript">
			
			function init() {
				CAuth.init("http://172.16.11.192:8000");
				CAuth.login(onLogin);
			}
			
			function logout() {
				CAuth.logout(onLogout);
			}
			
			function onLogin(isSaved) {
				if (isSaved) {
					document.getElementById("loginclick").style.display = 'none';
					document.getElementById("loggedin").style.display = 'block';
				}
				else {
					document.getElementById("loginclick").style.display = 'block';
					document.getElementById("loggedin").style.display = 'none';
				}
			}
			
			function onLogout() {
				CAuth.login(onLogin);
			}
			
		</script>
	</head>
	<body onload="init()">
		<div id="wrapper">
			<div id="main">
				<h1>CAuth login test</h1>
				<h2>This is a test for a cross-domain cookie login scheme.</h2>
					The way it works is that it looks for a local stored hash to be used as a key for the application.
					If none is present to begin with, LazyLoad calls a remote script that gets and sets remote cookies via
					the server's header responses.<br />
					
					<h2>Try it yourself</h2>
					<div id="loginclick">
						You are not logged in.<br />
						<a href="javascript:void(0);" onclick="CAuth.prompt(onLogin);">Click here to login</a>
					</div>
					<div id="loggedin">
						You are logged in!
						<a href="javascript:void(0);" onclick="logout();">Log out</a>
					</div>
			</div>
		</div>
	</body>
</html>
